home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu017.dms / pu017.adf / Graphics / Example7.c < prev    next >
C/C++ Source or Header  |  1990-01-30  |  4KB  |  141 lines

  1. /* Example7                                                            */
  2. /* This program will open a normal window which is connected to the    */
  3. /* Workbench Screen. We will then draw the nice 4 colour face that was */
  4. /* described in chapter 3.5 IMAGES.                                    */
  5.  
  6.  
  7.  
  8. /* If your program is using Intuition you should include intuition.h: */
  9. #include <intuition/intuition.h>
  10.  
  11.  
  12.  
  13. struct IntuitionBase *IntuitionBase;
  14.  
  15.  
  16.  
  17. /* Declare a pointer to a Window structure: */ 
  18. struct Window *my_window;
  19.  
  20. /* Declare and initialize your NewWindow structure: */
  21. struct NewWindow my_new_window=
  22. {
  23.   40,            /* LeftEdge    x position of the window. */
  24.   20,            /* TopEdge     y positio of the window. */
  25.   250,           /* Width       250 pixels wide. */
  26.   80,            /* Height      80 lines high. */
  27.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  28.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  29.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  30.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  31.   WINDOWDRAG|    /*             Drag gadget. */
  32.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  33.   ACTIVATE,      /*             The window should be Active when opened. */
  34.   NULL,          /* FirstGadget No Custom Gadgets. */
  35.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  36.   "THE 4 COLOUR FACE",/* Title  Title of the window. */
  37.   NULL,          /* Screen      Connected to the Workbench Screen. */
  38.   NULL,          /* BitMap      No Custom BitMap. */
  39.   0,             /* MinWidth    We do not need to care about these */
  40.   0,             /* MinHeight   since we have not supplied the window */
  41.   0,             /* MaxWidth    with a Sizing Gadget. */
  42.   0,             /* MaxHeight */
  43.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  44. };
  45.  
  46.  
  47.  
  48. /* REMEMBER! Image data MUST be put in chip-memory! */
  49. USHORT chip my_image_data[]= /* Image data for a nice four colour face: */
  50. {
  51.   0x3E00, /* Bitplane ZERO */
  52.   0x7F00,
  53.   0xC980,
  54.   0xBE80,
  55.   0xFF80,
  56.   0xFF80,
  57.   0xEB80,
  58.   0xEB80,
  59.   0xFF80,
  60.   0xDD80,
  61.   0x6300,
  62.   0x7F00,
  63.   0x3E00,
  64.  
  65.   0x3E00, /* Bitplane ONE */
  66.   0x7F00,
  67.   0xFF80,
  68.   0xFF80,
  69.   0xC980,
  70.   0xC980,
  71.   0xDD80,
  72.   0xDD80,
  73.   0xFF80,
  74.   0xFF80,
  75.   0x7F00,
  76.   0x7F00,
  77.   0x3E00
  78. };
  79.  
  80. struct Image my_image=
  81. {
  82.   40, 30,         /* LeftEdge, TopEdge. */
  83.   9,              /* Width, 9 pixels/bitts wide. */
  84.   13,             /* Height, 13 lines high. */
  85.   2,              /* Depth, two Bitplanes, 4 colours. */
  86.   my_image_data,  /* ImageData, pointer to my_image_data. */
  87.   0x0003,         /* PickPlane, bitplane Zero and One affects. */
  88.   0x0000,         /* PlaneOnOff, all Bitplanes are already "picked". */
  89.   NULL            /* NextImage, no more Images. */
  90. };
  91.  
  92.  
  93.  
  94. main()
  95. {
  96.   /* Open the Intuition Library: */
  97.   IntuitionBase = (struct IntuitionBase *)
  98.     OpenLibrary( "intuition.library", 0 );
  99.   
  100.   if( IntuitionBase == NULL )
  101.     exit(); /* Could NOT open the Intuition Library! */
  102.  
  103.  
  104.  
  105.   /* We will now try to open the window: */
  106.   my_window = (struct Window *) OpenWindow( &my_new_window );
  107.   
  108.   /* Have we opened the window succesfully? */
  109.   if(my_window == NULL)
  110.   {
  111.     /* Could NOT open the Window! */
  112.     
  113.     /* Close the Intuition Library since we have opened it: */
  114.     CloseLibrary( IntuitionBase );
  115.  
  116.     exit();  
  117.   }
  118.  
  119.  
  120.  
  121.   /* Tell Intuition to draw the face: */
  122.   DrawImage( my_window->RPort, &my_image, 0, 0 );
  123.  
  124.  
  125.  
  126.   /* We have opened the window, and everything seems to be OK. */
  127.   /* Wait for 30 seconds: */
  128.   Delay( 50 * 30);
  129.  
  130.  
  131.  
  132.   /* We should always close the windows we have opened before we leave: */
  133.   CloseWindow( my_window );
  134.  
  135.  
  136.   
  137.   /* Close the Intuition Library since we have opened it: */
  138.   CloseLibrary( IntuitionBase );
  139.   
  140.   /* THE END */
  141. }